***Real Data***
clear
postutil clear
use "Games.dta"

reshape long team exp win champ attend fips, i(gameid) j(num)
drop num
drop if fips == .

foreach i in G P S {
preserve
merge m:1 fips year using "electoral`i'.dta"
keep if _merge == 3
drop _merge
save "merged`i'.dta", replace
restore
}
clear
use "mergedG.dta"
append using "mergedP.dta"
append using "mergedS.dta"
replace game_date = subinstr(game_date, "-", "/", .)
replace electiondate = subinstr(electiondate, "-", "/", .)
g days_since = date(game_date, "YMD") - date(electiondate, "YMD")
keep if days_since >= -12 & days_since < 0


merge m:1 fips year using "demographics.dta"
keep if _merge == 3
drop _merge

*drop counties that had boundary changes or were consolidated
drop if drop == 1 | nonexist == 1

g weeksbefore = 2 
replace weeksbefore = 1 if days_since >= -5

g treatment = win - exp


egen team_type_year = group(team type year)
egen games = count(treatment), by(team_type_year)
egen treatment_pooled = sum(treatment), by(team_type_year)
replace treatment_pooled = . if games != 2 
g _2weeks = treatment if weeksbefore == 2
g _1week = treatment if weeksbefore == 1
egen treatment_2weeks = mean(_2weeks), by(team_type_year)
egen treatment_1week = mean(_1week), by(team_type_year)
drop _2weeks _1week
sort team_type_year
drop if team_type_year == team_type_year[_n-1]
drop game_date exp win treatment

*following Graham et al., drop if team didn't play both games
keep if games == 2
drop games

*g oldsample = year >= 1985 & year <= 2006

g t_2wk_attend = treatment_2weeks*attend
g t_1wk_attend = treatment_1week*attend
g t_pool_attend = treatment_pooled*attend

g t_2wk_champ = treatment_2weeks*champ
g t_1wk_champ = treatment_1week*champ
g t_pool_champ = treatment_pooled*champ




postfile Results coef pval specification sample using "Results.dta", replace


***Old Sample***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (1)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (1)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (1)

xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (1)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (1)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (1)

xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (1)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (1)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (1)

*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (1)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (1)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (1)

xi:reghdfe vote treatment_1week lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (1)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (1)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (1)

xi:reghdfe vote treatment_pooled lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (1)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (1)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (1)


***Extended Sample***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (2)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (2)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (2)

xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (2)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (2)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (2)

xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (2)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (2)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (2)

*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (2)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (2)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (2)

xi:reghdfe vote treatment_1week lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (2)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (2)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (2)

xi:reghdfe vote treatment_pooled lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (2)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (2)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (2)


***Out-of-sample years***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (3)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (3)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (3)

xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (3)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (3)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (3)

xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (3)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (3)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (3)

*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (3)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (3)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (3)

xi:reghdfe vote treatment_1week lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (3)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (3)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (3)

xi:reghdfe vote treatment_pooled lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (3)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (3)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (3)


postclose Results
clear
use "Results.dta"
g expecteddirection = coef > 0
g significant = pval < .025
table sample, stat(sum expecteddirection significant)
table sample, stat(mean pval)


***Simulations with no effect***
clear
postutil clear
set more off
set seed 60637

local reportevery = 100
local iterations = 10000

postfile NoEffect positive significant avgpval sample iteration using "NoEffect.dta", replace

forvalues j = 1/`iterations' {
quietly {


clear
use "Games.dta"

*randomly draw new game outcomes according to betting lines
drop win*
g random = uniform()
g win1 = random < exp1
g win2 = 1 - win1

reshape long team exp win champ attend fips, i(gameid) j(num)
drop num
drop if fips == .

foreach i in G P S {
preserve
merge m:1 fips year using "electoral`i'.dta"
keep if _merge == 3
drop _merge
tempfile merged`i'
save "`merged`i''", replace
restore
}
clear
use  "`mergedG'"
append using "`mergedP'"
append using "`mergedS'"
replace game_date = subinstr(game_date, "-", "/", .)
replace electiondate = subinstr(electiondate, "-", "/", .)
g days_since = date(game_date, "YMD") - date(electiondate, "YMD")
keep if days_since >= -12 & days_since < 0


merge m:1 fips year using "demographics.dta"
keep if _merge == 3
drop _merge

*drop counties that had boundary changes or were consolidated
drop if drop == 1 | nonexist == 1

g weeksbefore = 2 
replace weeksbefore = 1 if days_since >= -5

g treatment = win - exp

egen team_type_year = group(team type year)
egen games = count(treatment), by(team_type_year)
egen treatment_pooled = sum(treatment), by(team_type_year)
replace treatment_pooled = . if games != 2 
g _2weeks = treatment if weeksbefore == 2
g _1week = treatment if weeksbefore == 1
egen treatment_2weeks = mean(_2weeks), by(team_type_year)
egen treatment_1week = mean(_1week), by(team_type_year)
drop _2weeks _1week
sort team_type_year
drop if team_type_year == team_type_year[_n-1]
drop game_date exp win treatment

*following Graham et al., drop if team didn't play both games
keep if games == 2
drop games

g t_2wk_attend = treatment_2weeks*attend
g t_1wk_attend = treatment_1week*attend
g t_pool_attend = treatment_pooled*attend

g t_2wk_champ = treatment_2weeks*champ
g t_1wk_champ = treatment_1week*champ
g t_pool_champ = treatment_pooled*champ


postfile Results coef pval specification sample using "Results.dta", replace
***Old Sample***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (1)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (1)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (1)
xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (1)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (1)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (1)
xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (1)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (1)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (1)
*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (1)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (1)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (1)
xi:reghdfe vote treatment_1week lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (1)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (1)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (1)
xi:reghdfe vote treatment_pooled lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (1)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (1)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (1)
***Extended Sample***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (2)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (2)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (2)
xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (2)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (2)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (2)
xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (2)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (2)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (2)
*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (2)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (2)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (2)
xi:reghdfe vote treatment_1week lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (2)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (2)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (2)
xi:reghdfe vote treatment_pooled lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (2)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (2)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (2)
***Out-of-sample years***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (3)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (3)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (3)
xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (3)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (3)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (3)
xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (3)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (3)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (3)
*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (3)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (3)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (3)
xi:reghdfe vote treatment_1week lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (3)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (3)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (3)
xi:reghdfe vote treatment_pooled lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (3)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (3)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (3)
postclose Results
clear
use "Results.dta"
g positive = coef > 0
g significant = pval < .025

forvalues k = 1/3 {
sum positive if sample == `k'
scalar sum1 = r(sum)
sum significant if sample == `k'
scalar sum2 = r(sum)
sum pval if sample == `k'
scalar avgpval = r(mean)
post NoEffect (sum1) (sum2) (avgpval) (`k') (`j')
}
}
if (`j'/`reportevery') == round(`j'/`reportevery') {
	disp `j' " $S_DATE $S_TIME "
	}
}
postclose NoEffect
clear
use "NoEffect.dta"
reshape wide positive significant avgpval, i(iteration) j(sample)

sum *1 *2 *3
local total = r(N)

qui:count if positive1 >= 18
disp round((r(N)/`total')*1000)/1000
qui:count if significant1 >= 4
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval1 < .1858883
disp round((r(N)/`total')*1000)/1000

qui:count if positive2 >= 15
disp round((r(N)/`total')*1000)/1000
qui:count if significant2 >= 4
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval2 < .2774814
disp round((r(N)/`total')*1000)/1000

qui:count if positive3 >= 4
disp round((r(N)/`total')*1000)/1000
qui:count if significant3 >= 0
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval3 < .6301702
disp round((r(N)/`total')*1000)/1000

keep if positive1 >= 18 & significant1 >= 4
sum *2 *3

sum avgpval1
local total = r(N)

qui:count if positive2 >= 15
disp round((r(N)/`total')*1000)/1000
qui:count if significant2 >= 4
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval2 < .2774814
disp round((r(N)/`total')*1000)/1000

qui:count if positive3 >= 4
disp round((r(N)/`total')*1000)/1000
qui:count if significant3 >= 0
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval3 < .6301702
disp round((r(N)/`total')*1000)/1000


***Simulations with genuine effect***
clear
postutil clear
set more off
set seed 60637

local reportevery = 50
local iterations = 1000

postfile RealEffect positive significant avgpval sample iteration using "RealEffect.dta", replace

*set effect for high-attendance and championship teams at 2
*effect for others as 0.5
*so the average across all games is approximately 1
local higheffect = 2
local loweffect = .5

forvalues j = 1/`iterations' {
quietly {

clear
use "Games.dta"

*randomly draw new game outcomes according to betting lines
rename win1 winreal1
rename win2 winreal2

g random = uniform()
g win1 = random < exp1
g win2 = 1 - win1

reshape long team exp win winreal champ attend fips, i(gameid) j(num)
drop num
drop if fips == .

foreach i in G P S {
preserve
merge m:1 fips year using "electoral`i'.dta"
keep if _merge == 3
drop _merge
tempfile merged`i'
save "`merged`i''", replace
restore
}
clear
use  "`mergedG'"
append using "`mergedP'"
append using "`mergedS'"
replace game_date = subinstr(game_date, "-", "/", .)
replace electiondate = subinstr(electiondate, "-", "/", .)
g days_since = date(game_date, "YMD") - date(electiondate, "YMD")
keep if days_since >= -12 & days_since < 0


merge m:1 fips year using "demographics.dta"
keep if _merge == 3
drop _merge

*drop counties that had boundary changes or were consolidated
drop if drop == 1 | nonexist == 1

g weeksbefore = 2 
replace weeksbefore = 1 if days_since >= -5

g treatment = win - exp
g treatmentreal = winreal - exp

egen team_type_year = group(team type year)
egen games = count(treatment), by(team_type_year)
egen treatment_pooled = sum(treatment), by(team_type_year)
replace treatment_pooled = . if games != 2 
egen treatmentreal_pooled = sum(treatmentreal), by(team_type_year)
replace treatmentreal_pooled = . if games != 2 
g _2weeks = treatment if weeksbefore == 2
g _1week = treatment if weeksbefore == 1
egen treatment_2weeks = mean(_2weeks), by(team_type_year)
egen treatment_1week = mean(_1week), by(team_type_year)
drop _2weeks _1week
sort team_type_year
drop if team_type_year == team_type_year[_n-1]
drop game_date exp win treatment

*following Graham et al., drop if team didn't play both games
keep if games == 2
drop games


g t_2wk_attend = treatment_2weeks*attend
g t_1wk_attend = treatment_1week*attend
g t_pool_attend = treatment_pooled*attend

g t_2wk_champ = treatment_2weeks*champ
g t_1wk_champ = treatment_1week*champ
g t_pool_champ = treatment_pooled*champ

replace vote = vote - `higheffect'*treatmentreal_pooled + `higheffect'*treatment_pooled if champ == 1 | attend == 1
replace vote = vote - `loweffect'*treatmentreal_pooled + `loweffect'*treatment_pooled if champ == 0 & attend == 0


postfile Results coef pval specification sample using "Results.dta", replace
***Old Sample***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (1)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (1)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (1)
xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (1)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (1)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (1)
xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (1)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (1)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (1)
*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (1)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (1)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (1)
xi:reghdfe vote treatment_1week lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (1)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (1)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (1)
xi:reghdfe vote treatment_pooled lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (1)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (1)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type if year <= 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (1)
***Extended Sample***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (2)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (2)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (2)
xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (2)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (2)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (2)
xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (2)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (2)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (2)
*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (2)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (2)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (2)
xi:reghdfe vote treatment_1week lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (2)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (2)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (2)
xi:reghdfe vote treatment_pooled lagvote i.type, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (2)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (2)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (2)
***Out-of-sample years***
*demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (1) (3)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (2) (3)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (3) (3)
xi:reghdfe vote treatment_1week lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (4) (3)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (5) (3)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (6) (3)
xi:reghdfe vote treatment_pooled lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (7) (3)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (8) (3)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type blackpct unemp hspct faminc farm_per logpop if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (9) (3)
*no demographic controls
xi:reghdfe vote treatment_2weeks lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_2weeks]) (ttail(e(df_r),_b[treatment_2weeks]/_se[treatment_2weeks])) (10) (3)
xi:reghdfe vote treatment_2weeks t_2wk_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_attend]) (ttail(e(df_r),_b[t_2wk_attend]/_se[t_2wk_attend])) (11) (3)
xi:reghdfe vote treatment_2weeks t_2wk_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_2wk_champ]) (ttail(e(df_r),_b[t_2wk_champ]/_se[t_2wk_champ])) (12) (3)
xi:reghdfe vote treatment_1week lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_1week]) (ttail(e(df_r),_b[treatment_1week]/_se[treatment_1week])) (13) (3)
xi:reghdfe vote treatment_1week t_1wk_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_attend]) (ttail(e(df_r),_b[t_1wk_attend]/_se[t_1wk_attend])) (14) (3)
xi:reghdfe vote treatment_1week t_1wk_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_1wk_champ]) (ttail(e(df_r),_b[t_1wk_champ]/_se[t_1wk_champ])) (15) (3)
xi:reghdfe vote treatment_pooled lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[treatment_pooled]) (ttail(e(df_r),_b[treatment_pooled]/_se[treatment_pooled])) (16) (3)
xi:reghdfe vote treatment_pooled t_pool_attend lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_attend]) (ttail(e(df_r),_b[t_pool_attend]/_se[t_pool_attend])) (17) (3)
xi:reghdfe vote treatment_pooled t_pool_champ lagvote i.type if year > 2006, a(fips year) cluster(fips)
post Results (_b[t_pool_champ]) (ttail(e(df_r),_b[t_pool_champ]/_se[t_pool_champ])) (18) (3)
postclose Results
clear
use "Results.dta"
g positive = coef > 0
g significant = pval < .025

forvalues k = 1/3 {
sum positive if sample == `k'
scalar sum1 = r(sum)
sum significant if sample == `k'
scalar sum2 = r(sum)
sum pval if sample == `k'
scalar avgpval = r(mean)
post RealEffect (sum1) (sum2) (avgpval) (`k') (`j')
}
}
if (`j'/`reportevery') == round(`j'/`reportevery') {
	disp `j' " $S_DATE $S_TIME "
	}
}
postclose RealEffect
clear
use "RealEffect.dta"
reshape wide positive significant avgpval, i(iteration) j(sample)
*save "RealEffect_1000.dta", replace

sum *1 *2 *3
local total = r(N)

qui:count if positive1 <= 18
disp round((r(N)/`total')*1000)/1000
qui:count if significant1 <= 4
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval1 > .1858883
disp round((r(N)/`total')*1000)/1000

qui:count if positive2 <= 15
disp round((r(N)/`total')*1000)/1000
qui:count if significant2 <= 4
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval2 > .2774814
disp round((r(N)/`total')*1000)/1000

qui:count if positive3 <= 4
disp round((r(N)/`total')*1000)/1000
qui:count if significant3 <= 0
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval3 > .6301702
disp round((r(N)/`total')*1000)/1000

keep if positive1 >= 18 & significant1 >= 4
sum *2 *3
local total = r(N)

qui:count if positive2 <= 15
disp round((r(N)/`total')*1000)/1000
qui:count if significant2 <= 4
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval2 > .2774814
disp round((r(N)/`total')*1000)/1000

qui:count if positive3 <= 4
disp round((r(N)/`total')*1000)/1000
qui:count if significant3 <= 0
disp round((r(N)/`total')*1000)/1000
qui:count if avgpval3 > .6301702
disp round((r(N)/`total')*1000)/1000






